﻿@ModelType IEnumerable(Of Microsoft.Samples.WindowsPhoneCloud.Web.Models.UserPermissionsModel)
@Code
    ViewData("Title") = "Manage User Permissions"
End Code
<h2>
    Manage User Permissions</h2>
<p>
    Select what content type can access each user.
</p>
<table>
    <tr>
        <th class="left-aligned">
            User
        </th>
        <th>
            Tables
        </th>
        <th>
            Blobs
        </th>
        <th>
            Queues
        </th>
        <th>
            SQL
        </th>
    </tr>
    @Code 
        Dim i = 0
        For Each item In Me.Model
            i += 1
    End code
    <tr class="d@((i Mod 2))">
        <td class="left-aligned">
            @(item.UserName)
        </td>
        <td>
            @Code Dim tablesChecked = If(item.TablesUsage, "checked=""checked""", String.Empty)End Code
            <input id="Tables_@(item.UserId)" onclick="EnableContent('@(item.UserId)', actionUrl)"
                    type="checkbox" @Me.Html.Raw(tablesChecked) />
        </td>
        <td>
            @Code Dim blobsChecked = If(item.BlobsUsage, "checked=""checked""", String.Empty)End Code
            <input id="Blobs_@(item.UserId)" onclick="EnableContent('@(item.UserId)', actionUrl)"
                    type="checkbox" @Me.Html.Raw(blobsChecked) />
        </td>
        <td>
            @Code Dim queuesChecked = If(item.QueuesUsage, "checked=""checked""", String.Empty)End Code
            <input id="Queues_@(item.UserId)" onclick="EnableContent('@(item.UserId)', actionUrl)"
                    type="checkbox" @Me.Html.Raw(queuesChecked) />
        </td>
        <td>
            @Code Dim sqlChecked = If(item.SqlUsage, "checked=""checked""", String.Empty)End Code
            <input id="Sql_@(item.UserId)" onclick="EnableContent('@(item.UserId)', actionUrl)"
                    type="checkbox" @Me.Html.Raw(sqlChecked) />
        </td>
    </tr>
    @Code
        Next item
    End code
</table>
<script type="text/javascript">
//<![CDATA[
    var actionUrl = '@Me.Html.Raw(Me.Url.Action("SetUserPermissions", New With {Key .userId = "_user_", Key .useTables = "_useTables_", Key .useBlobs = "_useBlobs_", Key .useQueues = "_useQueues_", Key .useSql = "_useSql_"}))';
//]]>
</script>
